package com.chaoshi.common;

import com.chaoshi.strategy.PriceStrategy;
import com.chaoshi.strategy.impl.AllFruitsStrategy;
import com.chaoshi.strategy.impl.DiscountStrawberryDecorator;
import com.chaoshi.strategy.impl.FullReductionDecorator;
import com.chaoshi.strategy.impl.OriginalPriceStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class StrategyConfig {
    private final double STRAWBERRY_DISCOUNT = 0.8;
    private final int FULL_REDUCTION_THRESHOLD = 100;
    private final int FULL_REDUCTION_AMOUNT = 10;

    @Bean("A")
    public PriceStrategy customerA(FruitPrices prices) {
        return new OriginalPriceStrategy(prices);
    }

    @Bean("B")
    public PriceStrategy customerB(FruitPrices prices) {
        return new AllFruitsStrategy(prices);
    }

    @Bean("C")
    public PriceStrategy customerC(FruitPrices prices) {
        return new DiscountStrawberryDecorator(
                new AllFruitsStrategy(prices),
                STRAWBERRY_DISCOUNT
        );
    }

    @Bean("D")
    public PriceStrategy customerD(FruitPrices prices) {
        return new FullReductionDecorator(
                new DiscountStrawberryDecorator(
                        new AllFruitsStrategy(prices),
                        STRAWBERRY_DISCOUNT
                ),
                FULL_REDUCTION_THRESHOLD,
                FULL_REDUCTION_AMOUNT
        );
    }
}